﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TaskListManager
{
   [Serializable()]
   class TaskEntry
   {
      protected int m_lOwnerUserIdent;
      protected int m_lTaskIdent;
      protected string m_strEntryDesc;
      protected long m_lStartDate;
      protected long m_lEndDate;
      protected short m_nPercentComplete;
      protected bool m_bCompleted;

      public TaskEntry()
      {
         m_strEntryDesc = "";
         m_lOwnerUserIdent = 0;
         m_lStartDate = 0;
         m_lEndDate = 0;
         m_nPercentComplete = 0;
         m_lTaskIdent = 0;
         m_bCompleted = false;
      }

      public TaskEntry(TaskEntry sEntry)
      {
         m_strEntryDesc = sEntry.m_strEntryDesc;
         m_lStartDate = sEntry.m_lStartDate;
         m_lEndDate = sEntry.m_lEndDate;
         m_nPercentComplete = sEntry.m_nPercentComplete;
         m_lTaskIdent = sEntry.m_lTaskIdent;
         m_bCompleted = sEntry.m_bCompleted;
         m_lOwnerUserIdent = sEntry.m_lOwnerUserIdent;
      }

      public override int GetHashCode()
      {
         return (int)(m_strEntryDesc.GetHashCode() ^ m_lStartDate ^ m_lEndDate ^ m_nPercentComplete ^ m_lTaskIdent ^ m_lOwnerUserIdent);
      }

      public override bool Equals(object obj)
      {
         bool bRet = false;
         if (obj == null)
         {
            bRet = false;
         }
         else
         {
            TaskEntry sEntry = obj as TaskEntry;
            if (sEntry == null)
            {
               bRet = false;
            }
            else
            {
               bRet = (sEntry.m_lTaskIdent == m_lTaskIdent);
            }
         }
         return bRet;
      }

      public int OwnerUser
      {
         get
         {
            return m_lOwnerUserIdent;
         }
         set
         {
            m_lOwnerUserIdent = value;
         }
      }

      public bool Complete
      {
         get
         {
            return m_bCompleted;
         }
         set
         {
            m_bCompleted = value;
         }
      }

      public int TaskId
      {
         get
         {
            return m_lTaskIdent;
         }
         set
         {
            m_lTaskIdent = value;
         }
      }

      public long StartDate
      {
         get
         {
            return m_lStartDate;
         }
         set
         {
            m_lStartDate = value;
         }
      }

      public long EndDate
      {
         get
         {
            return m_lEndDate;
         }
         set
         {
            m_lEndDate = value;
         }
      }

      public short PercentComplete
      {
         get
         {
            return m_nPercentComplete;
         }
         set
         {
            if ((value >= 0) && (value <= 100))
            {
               m_nPercentComplete = value;
            }
         }
      }

      public string Description
      {
         get
         {
            return m_strEntryDesc;
         }
         set
         {
            m_strEntryDesc = value;
         }
      }
   }
}
